package com.baicai.baicaiknowledgeai.config;
import com.aliyun.bailian20231229.Client;
import com.aliyun.teaopenapi.models.Config;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@Data
public class AliyunKnowledgeBaseConfig {

    @Value("${aliyun.access-key-id}")
    private String accessKeyId;

    @Value("${aliyun.access-key-secret}")
    private String accessKeySecret;

    @Value("${aliyun.bailian.endpoint:bailian.cn-beijing.aliyuncs.com}")
    private String endpoint;

    @Value("${aliyun.bailian.workspace-id}")
    private String workspaceId;

    @Bean
    public Client bailianClient() throws Exception {
        Config config = new Config()
                .setAccessKeyId(accessKeyId)
                .setAccessKeySecret(accessKeySecret)
                .setEndpoint(endpoint);
        return new Client(config);
    }

    @Bean
    public String workspaceId() {
        return workspaceId;
    }
}